<template>
  <div>
    <div class="outmain ba_f heighthv pad_20 bor_rad5">
      <div class="shuju_title mar_b20">
        <div class="shuju_title_text">
          <span>点单页装修</span>
        </div>
      </div>
      <el-form ref="form" :model="form" label-width="180px" class="mar_t20">
        <el-form-item label="商品分类图标">
          <el-radio-group v-model="form.display">
            <el-radio label="1">不显示</el-radio>
            <el-radio label="2">上下布局</el-radio>
            <el-radio label="3">左右布局</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="商品加载方式">
          <el-radio-group v-model="form.goodload">
            <el-radio :label="1">加载全部商品</el-radio>
            <el-radio :label="2">按商品分类加载商品</el-radio>
          </el-radio-group>
          <div class="yb_margin lh16">建议在商品较多的情况下，选择按商品分类加载，减少页面载入时间</div>
        </el-form-item>
      </el-form>
    </div>
    <div class="mar_t20 ba_f pad_20 t_c">
      <el-button type="primary" @click="submitForm">保存</el-button>
    </div>
  </div>
</template>
<script>
  import {getConfig, postConfig} from "@/api/setup";
  export default {
    created() {
      this.bus.$emit('loading', true);
      this.init();
    },
    data () {
      return {
        form:{
          display:'1',
          goodload: 1,
        },
      }
    },
    methods: {
      async init() {
        const {data} = await getConfig({ident: 'showCategoryIcon'});
        this.form2 = this.form
        this.form = Object.assign(this.form2, data);
        this.bus.$emit('loading', false)
      },
      submitForm() {
        this.$refs["form"].validate(async (valid) => {
          if (valid) {
            this.form.ident = 'showCategoryIcon'
            this.form.identName = '商品分类图标'
            const {msg} = await postConfig(this.form);
            this.$baseMessage(msg, "success");
            this.init();
          } else {
            return false;
          }
        });
      },
    }
  }
</script>
